package com.company.behavioral.mediator_pattern.client;

import com.company.behavioral.mediator_pattern.concrete_colleague.*;
import com.company.behavioral.mediator_pattern.concrete_mediator.SubConcreteMediator;

/**
 * @ClassName Client1
 * @Author tiezheng.han
 * @Date 2020/9/4 17:52
 **/
public class Client1 {

    public static void main(String[] args) {
        // 用新增具体中介者定义中介者对象
        SubConcreteMediator mediator;
        mediator = new SubConcreteMediator();

        // 定义同事对象
        Button addBT = new Button();
        List list = new List();
        ComboBox cb = new ComboBox();
        TextBox userNameTextBox = new TextBox();
        Label label = new Label();

        addBT.setMediator(mediator);
        list.setMediator(mediator);
        cb.setMediator(mediator);
        userNameTextBox.setMediator(mediator);
        label.setMediator(mediator);

        mediator.addButton = addBT;
        mediator.list = list;
        mediator.cb = cb;
        mediator.userNameTextBox = userNameTextBox;
        mediator.label = label;

        addBT.changed();
        System.out.println("--------------------------");
        list.changed();
    }
}
